//
//  JMStudyCicleViewMode.m
//  VoluntaryStar
//
//  Created by xiaorui on 15/9/5.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMStudyCicleViewMode.h"
#import "JMAppNetworkClient.h"
#import "JMCircleQuestionMode.h"
#import "JMHeader.h"


@interface JMStudyCicleViewMode ()

+(NSMutableArray *)dataModel:(NSArray *)array;
@end

@implementation JMStudyCicleViewMode
+ (void) fetchStudeyCiccleMessageParametes:(NSDictionary *)dict  block:(ReturnBackMessage)block{
    [JMAppNetworkClient studyCircleListWithInfo:dict complete:^(id data, NSError *error) {
        NSMutableDictionary *downDict = (NSMutableDictionary *)data;
        if([[downDict objectForKey:@"status"] integerValue] == 1){
            NSMutableArray *array = [JMStudyCicleViewMode dataModel:data[@"list"]];
            block(data,error,array);
        }else{
            block(data,error,nil);
        }
    }];

}





+(NSMutableArray *)dataModel:(NSArray *)array{
    NSMutableArray *mArray = [[NSMutableArray alloc]initWithCapacity:0];
    for(int i = 0; i <array.count;i++){
        NSDictionary *dict = array [i];
        JMCircleQuestionMode *mode = [[JMCircleQuestionMode alloc]init];
        mode.countString =dict[@"count"];
        mode.questionId =  [dict[@"id"] intValue];
        mode.detailString = dict[@"detail"];
        mode.gradeString = dict[@"grade"];
        mode.loginString = dict[@"login"];
        mode.logoString = dict[@"logo"];
        mode.picString = dict[@"pic"];
        mode.subjectString = dict[@"subject"];
        mode.timeString = dict[@"time"];
        mode.uid = dict[@"uid"];
        if(i %2 == 0){
            mode.typeColor = UIColorFromRGB(0x64c225);
        }else{
            mode.typeColor = UIColorFromRGB(0xeb6100);
        }
        [mArray addObject:mode];
    }
    return mArray;
    
}

@end
